package com.library.control.log;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractFormController;

import com.library.model.dto.notice.NoticeDTO;
import com.library.model.service.NoticeService;

public class NoticeBoardWriteController extends AbstractFormController {
	
	private NoticeService noticeservice;
	

	public void setNoticeservice(NoticeService noticeservice) {
		this.noticeservice = noticeservice;
	}

	protected Object formBackingObject(HttpServletRequest request)
	throws Exception {
		String a_title=request.getParameter("a_title");
		String a_content=request.getParameter("a_content");

		NoticeDTO dto=new NoticeDTO(a_title, a_content);

		return dto;
} 

	@Override
	protected ModelAndView processFormSubmission(HttpServletRequest request,
			HttpServletResponse response, Object arg2, BindException arg3)
			throws Exception {
		noticeservice.insertNoticeWrite((NoticeDTO)arg2);
		return new ModelAndView("noticeok");
	}

	@Override
	protected ModelAndView showForm(HttpServletRequest request,
			HttpServletResponse response, BindException arg2) throws Exception {
		
		return new ModelAndView("noticeboardwrite");
	}
	
	

}
